<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <ul class="ul">
        <li>hello1</li>
        <li>hello2</li>
        <li>hello3</li>
        <li>hello4</li>
        <li>hello5</li>
    </ul>
</div>
<script>
    /*
    * insertBefore(node1,node2):在指定节点2前面添加节点1,一定要站在父亲的角度上添加
    * */
    var img = document.createElement("img");
    img.src = "./img/c1.jpg";
    img.alt = "这是一张图片";
    img.width = 200;
    var li1 = document.querySelector(".ul>li:nth-child(1)");
    li1.parentNode.insertBefore(img, li1);

</script>
</body>
</html>